import 'package:flutter/material.dart';

/// Created by XieXin on 2020/3/16.
/// 图片工具
class ImageUtils {
  static String getImgPath(String name,
      {String moduleName = '', String format = 'png'}) {
    if (moduleName == '') {
      return 'assets/images/$name.$format';
    } else {
      return '$moduleName/assets/images/$name.$format';
    }
  }

  static ImageProvider getAssetImageProvider(String name,
      {String moduleName = '', String format = "png"}) {
    return AssetImage(getImgPath(name, format: format, moduleName: moduleName));
  }

  static Image getImage(String name,
      {Color? color, String moduleName = '', String format = "png"}) {
    return Image.asset(
      getImgPath(name, format: format, moduleName: moduleName),
      color: color,
    );
  }
}
